package zyq;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import zyq.dao.UserDao;
import zyq.po.User;

import java.io.IOException;
import java.io.Reader;
import java.util.HashMap;
import java.util.List;

public class Test2 {

    public static void main(String[] args) throws IOException {
        Reader reader = Resources.getResourceAsReader("mybatis-conf.xml");
        SqlSessionFactory factory=new SqlSessionFactoryBuilder().build(reader);
        SqlSession sqlSession=factory.openSession();

        /*UserDao dao=sqlSession.getMapper(UserDao.class);
        User user=new User();
        user.setUserName1("张");
        List<User> users=dao.findUserLike(user);
        System.out.println(users);*/


        UserDao dao=sqlSession.getMapper(UserDao.class);
        /*List<User> users=dao.findUsers(1,5);
        System.out.println(users);*/



        User user=new User();
        user.setId(1);
        User u=dao.findUserById2(user);
        System.out.println(u);


        /*HashMap map=new HashMap();
        map.put("start",1);
        map.put("n",5);
        List<User> users=sqlSession.selectList("zyq.dao.UserDao.findUsers",map);
        System.out.println(users);*/

    }

}
